const { ownerModel } = require('../modules/ownerModel');

async function addowner(req, res, next) {
    const data = req.body;
    const ownerIdentityCard = await ownerModel.find({ ownerIdentityCard: data.ownerIdentityCard })
    if (ownerIdentityCard.length > 0) {
        res.send({
            message: '住户新增失败',
            code: 500,
        })
    } else {
        await ownerModel.create(data);
        res.send({
            message: '住户新增成功',
            code: 200,
        })
    }
}

async function getowner(req, res, next) {
    // const { nowPage, pageSize, value, cmd } = req.require;

    const data = await ownerModel.find();
    if (data.length > 0) {
        res.send({
            message: '房屋数据获取成功',
            code: 200,
            data
        })
    } else {
        res.send({
            message: '房屋数据获取失败',
            code: 500,

        })
    }
}



module.exports = { addowner, getowner }